/*
 * SafeArray.h
 *
 *  Created on: 2014. 7. 2.
 *      Author: jjaehuny
 */

#ifndef FRAMEWORK_DATASTRUCTURE_SAFEARRAY_H_
#define FRAMEWORK_DATASTRUCTURE_SAFEARRAY_H_

#include <array>

#include <boost/optional.hpp>

namespace Framework { namespace DataStructure {

template<class Type, long unsigned int size>
class SafeArray
{
public:
	SafeArray() noexcept {}
	~SafeArray() {}

public:
	bool SetValue(int index, Type type)
	{
		if (index < 0 or index >= size)
			return false;

		clsArray_[index] = type;
		return true;
	}

	bool GetValue(int index, Type & refType)
	{
		if (index < 0 or index >= size)
			return false;

		refType = clsArray_[index];
		return true;
	}

	boost::optional<int> GetValue(int index)
	{
		if (index < 0 or index >= size)
			return boost::optional<int>();

		boost::optional<int>(clsArray_[index]);
	}

private:
	std::array<Type, size> clsArray_;
};

} /*DataStructure*/ } /*Framework*/


#endif /* FRAMEWORK_DATASTRUCTURE_SAFEARRAY_H_ */
